package com.xuecheng.media.controller;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.po.QueryCourseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.api.media.model.api.MediaAuditApi;
import com.xuecheng.api.media.model.dto.MediaAuditDTO;
import com.xuecheng.api.media.model.dto.MediaDTO;
import com.xuecheng.api.media.model.vo.MediaAuditVO;
import com.xuecheng.api.media.model.vo.MediaVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.media.convert.MediaConvert;
import com.xuecheng.media.service.MediaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class MediaAuditController implements MediaAuditApi {

    // 运营平台标识--可以查询所哟教学机构的数据
    public static final Long OPERATION_FLAG = -99887799L;

    @Autowired
    private MediaService mediaService;


    @PostMapping("m/media/list")
    @Override
    public PageVO<MediaDTO> queryMediaList(PageRequestParams params,@RequestBody MediaVO vo) {

        return mediaService.queryMedia(params,vo,OPERATION_FLAG);
    }




    @PutMapping("m/media/audit")
    public void approveMedia(@RequestBody MediaAuditVO vo) {


        MediaAuditDTO mediaDTO = MediaConvert.INSTANCE.vo2dto(vo);

        mediaService.approveMedia(mediaDTO);
    }

    @GetMapping("m/media/preview/{mediaId}")
    public String mediaPriview(@PathVariable int mediaId) {



        return mediaService.mediaPriview(mediaId,OPERATION_FLAG);
    }


}
